use criterion::{criterion_group, criterion_main, Criterion};
use binomial_heap::binomial_heap::{BinomialHeap, BinomialHeapType};

fn binomial_heap_new_benchmark(c: &mut Criterion) {
    c.bench_function("binomial_heap_new", |b| {
        b.iter(|| BinomialHeap::<i32>::new(BinomialHeapType::Min))
    });
}

fn binomial_heap_insert_benchmark(c: &mut Criterion) {
    let mut heap = BinomialHeap::<i32>::new(BinomialHeapType::Min).unwrap();
    c.bench_function("binomial_heap_insert", |b| {
        b.iter(|| heap.insert(42))
    });
}

fn binomial_heap_pop_benchmark(c: &mut Criterion) {
    let mut heap = BinomialHeap::<i32>::new(BinomialHeapType::Min).unwrap();
    heap.insert(42);
    c.bench_function("binomial_heap_pop", |b| {
        b.iter(|| heap.pop())
    });
}

fn binomial_heap_merge_benchmark(c: &mut Criterion) {
    let mut heap1 = BinomialHeap::<i32>::new(BinomialHeapType::Min).unwrap();
    let mut heap2 = BinomialHeap::<i32>::new(BinomialHeapType::Min).unwrap();
    heap1.insert(42);
    heap2.insert(24);
    c.bench_function("binomial_heap_merge", |b| {
        b.iter(|| heap1.merge(&mut heap2))
    });
}

criterion_group!(
    benches,
    binomial_heap_new_benchmark,
    binomial_heap_insert_benchmark,
    binomial_heap_pop_benchmark,
    binomial_heap_merge_benchmark
);
criterion_main!(benches);